package com.tqyan.model.enums;

import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

/**
 * @description 会话创造力
 * <p> <功能详细描述> </p>
 *
 * @author 陈晨
 * @date 2023/4/11 17:51
 */
@Getter
@AllArgsConstructor
public enum ChatCreativeAbilityEnum {

    /**
     * 温度2.0：必定乱码，且都会超时
     * 温度1.5：极大概率乱码，但回答可以结束
     * 温度1.0：正常回答
     * 温度0.5：回答比较靠谱，但不会扩散太多内容
     * 温度0.1：与0.5没有什么太大差别
     */
    TEMPERATURE_0_5(0, "墨守成规", 5),
    TEMPERATURE_1_0(1, "匠心独运", 10),
//    TEMPERATURE_0_5(1, "蓝图初现", 5),
//    TEMPERATURE_1_5(3, "不拘一格", 15),
//    TEMPERATURE_2_0(4, "奇思妙想", 20),
    ;

    private final int value;
    private final String desc;
    private final int temperature;

    public static ChatCreativeAbilityEnum get(Integer value) {
        if (null == value) {
            return null;
        }
        return Arrays.stream(ChatCreativeAbilityEnum.values())
                .filter(e -> e.value == value).findFirst().orElse(TEMPERATURE_1_0);
    }

    public static ChatCreativeAbilityEnum getByDesc(String desc) {
        if (StringUtils.isBlank(desc)) {
            return null;
        }
        return Arrays.stream(ChatCreativeAbilityEnum.values())
                .filter(e -> e.desc.equals(desc)).findFirst().orElse(null);
    }

    public static Integer getValueByDesc(String desc) {
        ChatCreativeAbilityEnum getEnum = Arrays.stream(ChatCreativeAbilityEnum.values())
                .filter(e -> e.desc.equals(desc)).findFirst().orElse(null);
        if (null == getEnum) {
            return null;
        }
        return getEnum.getValue();
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }

}
